package dryworks.jsf.examples.generator;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import dryworks.examples.create.model.CreateExampleTask;

public class SiteGeneratorRunner {
	public static String calculateCurrentWorkingDirName() {
		String curDirName = System.getProperty("user.dir");
		return curDirName;
	}

	public static File calculateCurrentWorkingDir() {
		String curDir = calculateCurrentWorkingDirName();
		return new File(curDir);
	}

	public static File calculateCurrentWorkspaceDir() {
		File curDir = calculateCurrentWorkingDir();
		return curDir.getParentFile();
	}

	String[] complexTableExampleNames = { "TableWithEditInRow",
			"TableWithEditInPopup", "TableWithEditOnRowclick",
			"TableWithEditOnCellClick", "TableWithColspanInHeader",
			"TableWithColspanInRows", "TableWithTotals",
			"TableWithDynamicRowStyle", "TableWithCustomCellStyle",
			"AddRowToTableWithWizardPopupDialog", "TableParentAndTableChild",
			"TableWithDynamicColumns", "TableWithUnknownNumberOfColumns",
			"NewspaperTableFlow", "TableReversed", "TableWithFilter",
			"TableWithKeyListener", "TableWithExcellPrintEmail",
			"TableWithGraph", "TableWithRowManualSortingWithButtons",
			"TableWithRowManualSortingWithDragAndDrop",
			"SideBySideSetSortingWithButtons",
			"SideBySideSetSortingWithDragAndDrop", "MasterDetailsTable",
			"MasterDetailsTableWithSortAndFilter",
			"MasterDetailsTableWithEdit", "MasterDetailsTableWithRowSelection",
			"MasterDetailsTableWithClientSideCashing" };

	String[] complexTreeExamples = { "TreeWithToolBar", "TreeWithScroll",
			"TreeWithFilter", "NoIconsTree", "ChangeTreeStructure",
			"OnSelectNodeEvent", "VisitedTreeNodeStyling",
			"CustomDynamicRenderingInNodes", "UpBackForwardAction",
			"AddDeleteEditTreeNode", "MoveTreeNodesByDragAndDrop",
			"SideBySideTreesWithDragAndDrop", "DragFromTableToTree" };

	String[] layoutExamples = { "borderLayoutWithMenues",
			"borderLayoutPortletStyle", "eclipseLikeLayoutWithoutTabs",
			"eclipseLikeLayoutWithTabs",
			"eclipseLikeLayoutWithTabsAndDragAndDrop", "gridLayoutWithColsSpan" };

	String[] navigationExamples = { "SimpleNavigationWithButtonsLinks",
			"NavigationWithMenu", "BackForwardExample", "BreadCrumps",
			"FindAndReturnWithResult", "CallingSubprocessAndReturnWithResult",
			"SavingFlowState", "SeveralParallelFlows" };

	String[] dataModelExample = { "treeProvider", "chainedTreeProvider",
			"tableContentProvider" };

	public List<CreateExampleTask> constructComponentsExamplesCreationTasksList() {
		List<CreateExampleTask> tasks = new ArrayList<CreateExampleTask>();

		CreateExampleTask createEffect = new CreateExampleTask("effect",
				new String[] { "GalleryOfEffects", "EffectInTable" });
		tasks.add(createEffect);

		CreateExampleTask createPanelBorder = new CreateExampleTask(
				"panelBorder", new String[] { "GalleryOfPanelBorder" });
		tasks.add(createPanelBorder);

		CreateExampleTask createDataPaginator = new CreateExampleTask(
				"dataPaginator", "DataPaginatorCustomization");
		tasks.add(createDataPaginator);

		CreateExampleTask createCheckbox = new CreateExampleTask("checkbox",
				new String[] { "GroupsOfCheckBoxes", "CheckBoxChangeEvents",
						"DisableCheckBox", "CheckboxInDataTable" });
		tasks.add(createCheckbox);

		CreateExampleTask createCommandButton = new CreateExampleTask(
				"commandButton", new String[] { "GroupsOfCommandButtons",
						"CommandButtonsAsCheckboxes", "CommandButtonsAsRadio",
						"CommandButtonCustomization" });
		tasks.add(createCommandButton);

		CreateExampleTask createCommandLink = new CreateExampleTask(
				"commandLink", new String[] { "CommandLinkAsImage",
						"GroupsOfCommandLinks", "CommandLinksInDataTable",
						"CommandLinkCustomization" });
		tasks.add(createCommandLink);

		CreateExampleTask createDataTable = new CreateExampleTask("dataTable",
				new String[] { "DataTableWithHeaderRow",
						"DataTableWithSortHeader", "DataTableWithColumns",
						"DataTableWithColumnsGroup",
						"DataTableWithDataPaginator",
						"DataTableWithRowSelector" });
		tasks.add(createDataTable);

		CreateExampleTask createForm = new CreateExampleTask("form",
				new String[] { "EventsOnForm" });
		tasks.add(createForm);

		CreateExampleTask createGraphicImage = new CreateExampleTask(
				"graphicImage", new String[] { "DynamicImage", "EventsOnImage" });
		tasks.add(createGraphicImage);

		CreateExampleTask createInputHidden = new CreateExampleTask(
				"inputHidden", "SettingHiddenInputValue");
		tasks.add(createInputHidden);

		CreateExampleTask createInputSecret = new CreateExampleTask(
				"inputSecret", new String[] { "DynamicPasswordCheck" });
		tasks.add(createInputSecret);

		CreateExampleTask createInputText = new CreateExampleTask("inputText",
				new String[] { "InputTextWithDifferentDataTypes", "InputTextWithDifferentDataTypesAndConverters", "InputTextWithAutocompletion",
				"InputTextDisabled", "InputTextWithEvents", "InputTextWithValidation" });
		tasks.add(createInputText);

		CreateExampleTask createInputTextarea = new CreateExampleTask(
				"inputTextarea", new String[] { "InputTextAreaWithEvents" });
		tasks.add(createInputTextarea);

		CreateExampleTask createMessage = new CreateExampleTask("message",
				new String[] { "MessageCustomization" });
		tasks.add(createMessage);

		CreateExampleTask createMessages = new CreateExampleTask("messages",
				new String[] { "MessagesCustomization" });
		tasks.add(createMessages);

		CreateExampleTask createOutputFormat = new CreateExampleTask(
				"outputFormat", new String[] { "GalleryOfFormats" });
		tasks.add(createOutputFormat);

		CreateExampleTask createOutputLabel = new CreateExampleTask(
				"outputLabel");
		tasks.add(createOutputLabel);

		CreateExampleTask createOutputLink = new CreateExampleTask(
				"outputLink", new String[] { "OutputLinksInDataTable" });
		tasks.add(createOutputLink);

		CreateExampleTask createOutputText = new CreateExampleTask(
				"outputText",
				new String[] { "OutputTextWithDifferentBindingTypes", "OutputTextWithEffects" });
		tasks.add(createOutputText);

		CreateExampleTask createPanelGrid = new CreateExampleTask("panelGrid",
				new String[] { "GalleryOfPanelGrids" });
		tasks.add(createPanelGrid);

		CreateExampleTask createPanelGroup = new CreateExampleTask(
				"panelGroup", new String[] { "GalleryOfPanelGroups" });
		tasks.add(createPanelGroup);

		CreateExampleTask createRadio = new CreateExampleTask("radio",
				new String[] { "RadioChangeEvent", "RadioInDataTable" });
		tasks.add(createRadio);

		CreateExampleTask createSelectBooleanCheckbox = new CreateExampleTask(
				"selectBooleanCheckbox");
		tasks.add(createSelectBooleanCheckbox);

		CreateExampleTask createSelectManyCheckbox = new CreateExampleTask(
				"selectManyCheckbox");
		tasks.add(createSelectManyCheckbox);

		CreateExampleTask createSelectManyListbox = new CreateExampleTask(
				"selectManyListbox");
		tasks.add(createSelectManyListbox);

		CreateExampleTask createSelectManyMenu = new CreateExampleTask(
				"selectManyMenu");
		tasks.add(createSelectManyMenu);

		CreateExampleTask createSelectOneListbox = new CreateExampleTask(
				"selectOneListbox");
		tasks.add(createSelectOneListbox);

		CreateExampleTask createSelectOneMenu = new CreateExampleTask(
				"selectOneMenu");
		tasks.add(createSelectOneMenu);

		CreateExampleTask createSelectOneRadio = new CreateExampleTask(
				"selectOneRadio");
		tasks.add(createSelectOneRadio);

		CreateExampleTask createInputRichText = new CreateExampleTask(
				"inputRichText");
		tasks.add(createInputRichText);

		CreateExampleTask createMenuBar = new CreateExampleTask("menuBar",
				new String[] { "DynamicMenuBar", "MenuBarWithSeparator" });
		tasks.add(createMenuBar);

		CreateExampleTask createMenuPopup = new CreateExampleTask("menuPopup",
				new String[] { "ContentSensitiveMenuPopup" });
		tasks.add(createMenuPopup);

		CreateExampleTask createOutputChart = new CreateExampleTask(
				"outputChart", new String[] { "GalleryOfCharts",
						"CustomizingChart", "ChartWithDynamicData" });
		tasks.add(createOutputChart);

		CreateExampleTask createOutputConnectionStatus = new CreateExampleTask(
				"outputConnectionStatus",
				new String[] { "GalleryPossibleStatesOfOutputConnectionStatus" });
		tasks.add(createOutputConnectionStatus);

		CreateExampleTask createOutputHtml = new CreateExampleTask(
				"OutputHtmlWithHeadBodyOutputDeclarationOutputStyle",
				new String[] { "PageWithDynamicLocale", "PageWithDynamicStyle" });
		createOutputHtml.setNeedInclude(false);
		tasks.add(createOutputHtml);

		CreateExampleTask createOutputMedia = new CreateExampleTask(
				"outputMedia");
		tasks.add(createOutputMedia);

		CreateExampleTask createOutputStyle = new CreateExampleTask(
				"outputStyle");
		tasks.add(createOutputStyle);

		CreateExampleTask createPanelCollapsible = new CreateExampleTask(
				"panelCollapsible", new String[] {
						"SettingStateOfPanelCollapsible",
						"CustomizingPanelCollapsible" });
		tasks.add(createPanelCollapsible);

		CreateExampleTask createPanelDivider = new CreateExampleTask(
				"panelDivider");
		tasks.add(createPanelDivider);

		CreateExampleTask createPanelLayout = new CreateExampleTask(
				"panelLayout", new String[] { "GallaryOfPanelLayout" });
		tasks.add(createPanelLayout);

		CreateExampleTask createPanelPopup = new CreateExampleTask(
				"panelPopup", new String[] { "PanelPopupWithSubPopup",
						"ConfirmationPopup", "MessagePopupsGallery",
						"InputFieldsInPanelPopup", "GalleryOfPopups",
						"DialogPopup", "WizardPopup", "PreferencesAsPopup",
						"PanelPopupWithDataTable" });
		tasks.add(createPanelPopup);

		CreateExampleTask createPanelSeries = new CreateExampleTask(
				"panelSeries", new String[] { "GalleryPanelSeries" });
		tasks.add(createPanelSeries);

		CreateExampleTask createPanelStack = new CreateExampleTask(
				"panelStack", new String[] { "GalleryOfPanelStack" });
		tasks.add(createPanelStack);

		CreateExampleTask createPanelTab = new CreateExampleTask("panelTab",
				new String[] { "panelTabWithTabChangeListener",
						"panelTabWithTabSet" });
		tasks.add(createPanelTab);

		CreateExampleTask createPanelTooltip = new CreateExampleTask(
				"panelTooltip", new String[] { "GalleryPanelToolTip" });
		tasks.add(createPanelTooltip);

		CreateExampleTask createOutputProgress = new CreateExampleTask(
				"outputProgress", new String[] { "GalleryOfOutputProgress" });
		tasks.add(createOutputProgress);

		CreateExampleTask createSelectInputDate = new CreateExampleTask(
				"selectInputDate", new String[] {
						"SelectInputDateChangeEvents",
						"CustomizingSelectInputDate" });
		tasks.add(createSelectInputDate);

		CreateExampleTask createSelectInputText = new CreateExampleTask(
				"selectInputText", new String[] {
						"SelectInputTextChangeEvents",
						"CustomizingSelectInputText" });
		tasks.add(createSelectInputText);

		CreateExampleTask createTree = new CreateExampleTask("tree",
				new String[] { "TreeWithCheckboxes", "TreeWithSelection",
						"TreeForFileSystem", "TreeNoRootNode",
						"TreeWithPersistantState", "TreeWithSearch",
						"TreeWithLeafExpended", "TreeWithKeyListener" });
		tasks.add(createTree);

		CreateExampleTask createPanelPositioned = new CreateExampleTask(
				"panelPositioned");
		tasks.add(createPanelPositioned);

		return tasks;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			SiteGenerator siteGenerator = new SiteGenerator();
			siteGenerator.getSiteForExamples().setProjectName("TestICEFaces");

			File projectFolder = new File(calculateCurrentWorkspaceDir(),
					"TestICEFaces");
			siteGenerator.setRootProjectFolder(projectFolder);

			// List<CreateExampleTask> tasks = new
			// ArrayList<CreateExampleTask>();
			CreateExampleTask createInputText = new CreateExampleTask("inputText",
					new String[] { "InputTextWithDifferentDataTypes", "InputTextWithDifferentDataTypesAndConverters", "InputTextWithAutocompletion",
					"InputTextDisabled", "InputTextWithEvents", "InputTextWithValidation" });

			CreateExampleTask createOutputText = new CreateExampleTask(
					"outputText",
					new String[] { "OutputTextWithEffects" });
			
			siteGenerator.getExamplesList().add(createInputText);
			siteGenerator.getExamplesList().add(createOutputText);
			siteGenerator.generateAll();
			// siteGenerator
			// .visitDirStructure(
			// projectFolder,
			// new IFileFisitor[] { new GenerateAdditionalJspFilesForExamples()
			// },
			// null);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
